/**
 * 
 */
package com.geezdata.cps.ttk.domain.factory;

import java.util.Date;

import com.geezdata.cps.base.utils.BeanUtil;
import com.geezdata.cps.ttk.domain.domain.Sharer;

public class SharerFactory {
	public static Sharer newInstance(Sharer request , Sharer existSharer) {
		Sharer sharer = BeanUtil.convert(request,Sharer.class);
    	Date now = new Date();
    	if (existSharer == null) {
			sharer.setCreatedUser("system");
			sharer.setCreatedAt(now);
			sharer.setStatus(1);
    	} else {
    		if(existSharer.getRefererId() != null) {
    			sharer.setRefererId(existSharer.getRefererId());
			}
			sharer.setSharerId(existSharer.getSharerId());
    	}
		sharer.setUpdatedUser("system");
		sharer.setUpdatedAt(now);
        return sharer;
    }
}
